#![no_std]
#![no_main]

use cmsis_rtos2::{os_delay, os_kernel_initialize, os_kernel_start, static_rtos::thread::{Task, Thread, ThreadMem}, system_init};
use periph_utils::{entry, pre_init};
use defmt_rtt as _;
mod error;
mod utils;
mod net;

#[pre_init]
unsafe fn init() {
    system_init();
}

static APP_TASK_MEM: ThreadMem<4096> = ThreadMem::const_new();

struct AppTask;

impl Task for AppTask {

    fn run(&self) {
        defmt::println!("app run");
        net::net_run().unwrap();
        loop {
            os_delay(500);
        }
    }
}


#[entry]
fn main() -> ! {
    os_kernel_initialize();
    Thread::spawn(&AppTask, &APP_TASK_MEM);
    os_kernel_start();
    loop {}
}   


